home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gtlayout.lha
/
Source
/
LT_HandleInput.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-09
|
48KB
|
2,190 lines
/*
** GadTools layout toolkit
**
** Copyright © 1993-1998 by Olaf `Olsen' Barthel
** Freely distributable.
**
** :ts=4
*/
#ifndef _GTLAYOUT_GLOBAL_H
#include "gtlayout_global.h"
#endif
/*****************************************************************************/
#include <clib/keymap_protos.h>
#include <pragmas/keymap_pragmas.h>
/*****************************************************************************/
#include "Assert.h"
/*****************************************************************************/
STATIC LONG
CurrentWrap(ObjectNode *Node,LONG Current)
{
if(Current > Node->Max)
Current = Node->Min;
else
{
if(Current < Node->Min)
Current = Node->Max;
}
return(Current);
}
STATIC BOOL
CurrentInBounds(ObjectNode *Node,LONG Current)
{
return((BOOL)(Node->Min <= Current && Current <= Node->Max && Current != Node->Current));
}
/****** gtlayout.library/LT_HandleInput ******************************************
*
* NAME
* LT_HandleInput -- Filter IntuiMessage data.
*
* SYNOPSIS
* LT_HandleInput(Handle,Qualifier,Class,Code,Gadget);
* A0 D0 A1 A2 A3
*
* VOID LT_HandleInput(LayoutHandle *,ULONG,ULONG *,
* UWORD *,struct Gadget **);
*
* FUNCTION
* In order to keep track of user interface actions, such as
* keys getting pressed, sliders getting moved, etc. your
* code is to call LT_HandleInput() with data copied from the
* IntuiMessage it has just received and replied.
*
* INPUTS
* Handle - Pointer to a LayoutHandle structure.
*
* Qualifier - The Qualifier value copied from the
* IntuiMessage structure.
*
* Class - Pointer to the ULONG variable which holds the
* value copied from the Class entry of the
* IntuiMessage structure.
*
* Code - Pointer to the UWORD variable which holds the
* value copied from the Code entry of the
* IntuiMessage structure.
*
* Gadget - Pointer to the Gadget value copied from the
* IAddress entry of the IntuiMessage structure.
*
* RESULT
* none
*
* EXAMPLE
* struct IntuiMessage *IntuiMessage;
* ULONG Qualifier,Class;
* UWORD Code;
* struct Gadget *Gadget;
*
* for(;;)
* {
* WaitPort(Window->UserPort);
*
* while(IntuiMessage = GT_GetIMsg(Window->UserPort))
* {
* Class = IntuiMessage->Class;
* Code = IntuiMessage->Code;
* Qualifier = IntuiMessage->Qualifier;
* Gadget = IntuiMessage->Gadget;
*
* GT_ReplyIMsg(IntuiMessage);
*
* LT_HandleInput(Handle,Qualifier,&Class,&Code,&Gadget);
* }
* }
*
* NOTES
* For BOOPSI_KIND objects keystroke activation may lead to
* unexpected results. Your application will hear a IDCMP_GADGETUP
* event, the IntuiMessage->Code value will hold the ANSI key
* code of the key the user pressed.
*
* Do not call this routine before you have actually
* replied the IntuiMessage received or weird things
* may happen. This is not a suggestion, it's a threat.
*
******************************************************************************
*
*/
VOID LIBENT
LT_HandleInput(REG(a0) LayoutHandle *Handle,REG(d0) ULONG MsgQualifier,REG(a1) ULONG *MsgClass,REG(a2) UWORD *MsgCode,REG(a3) struct Gadget **MsgGadget)
{
ObjectNode *Node;
BOOL Activate;
if(!Handle)
return;
if(Handle->Failed)
{
*MsgClass = IDCMP_CLOSEWINDOW;
if(!Handle->NeedDelay)
Handle->NeedDelay = TRUE;
else
LTP_Delay(0,500000); // Give the guy a break
return;
}
Activate = FALSE;
switch(*MsgClass)
{
case IDCMP_CHANGEWINDOW:
if(!(Handle->Window->Flags & WFLG_SIZEGADGET) && (Handle->Window->Flags & WFLG_HASZOOM) && !V39)
{
#ifdef DO_BOOPSI_KIND
{
if(Handle->BOOPSIList)
RefreshGList((struct Gadget *)Handle->BOOPSIList,Handle->Window,NULL,(UWORD)-1);
}
#endif /* DO_BOOPSI_KIND */
RefreshGList(Handle->List,Handle->Window,NULL,(UWORD)-1);
GT_RefreshWindow(Handle->Window,NULL);
LTP_DrawGroup(Handle,Handle->TopGroup);
}
break;
case IDCMP_NEWSIZE:
// Did the user cancel the resize operation?
if(Handle->SizeVerified && Handle->SizeWidth == Handle->Window->Width && Handle->SizeHeight == Handle->Window->Height)
{
Handle->SizeVerified = FALSE;
Handle->SizeWidth = 0;
Handle->SizeHeight = 0;
// Put the gadgets back in
AddGList(Handle->Window,Handle->List,(UWORD)-1,(UWORD)-1,NULL);
}
else
{
struct IBox Box;
Handle->SizeWidth = 0;
Handle->SizeHeight = 0;
Box.Left = 0;
Box.Top = 0;
Box.Width = Handle->Window->Width;
Box.Height = Handle->Window->Height;
LT_LockWindow(Handle->Window);
if((Handle->ResizeObject != NULL) && (Handle->ResizeObject->Type == LISTVIEW_KIND))
Handle->ResizeObject->Special.List.IgnoreListContents = TRUE;
LT_RebuildTags(Handle,TRUE,
LAWN_Bounds, &Box,
TAG_DONE);
LT_UnlockWindow(Handle->Window);
if(Handle->Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
*MsgClass = NULL;
}
break;
case IDCMP_REFRESHWINDOW:
if(Handle->AutoRefresh)
{
LT_BeginRefresh(Handle);
LT_EndRefresh(Handle,TRUE);
*MsgClass = NULL;
}
break;
case IDCMP_INTUITICKS:
if(Handle->ActiveIncrementer)
{
if(Handle->IncrementerCountdown > 0)
Handle->IncrementerCountdown--;
if(Handle->IncrementerCountdown <= 0)
{
if(Handle->ActiveIncrementer->Host->Flags & GFLG_SELECTED)
{
if(Handle->ActiveIncrementer->Type == TAPEDECK_KIND)
{
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Handle->ActiveIncrementer->Host;
}
else
{
ObjectNode *Parent;
LONG Number;
if(Handle->IncrementerAccelerate > 0 && !(MsgQualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)))
Handle->IncrementerAccelerate--;
if(Handle->IncrementerAccelerate <= 0)
{
Handle->IncrementerAccelerate = 10;
Handle->IncrementerIncrement *= 2;
}
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Handle->ActiveIncrementer->Special.Incrementer.Parent;
Parent = (*MsgGadget)->UserData;
if(Parent->Type == FRACTION_KIND)
{
STRPTR String;
String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
{
LT_SetAttributes(Handle,Parent->ID,
GTST_String,String,
TAG_DONE);
}
}
else
{
if(Parent->Special.Integer.IncrementerHook)
Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
else
Number = ((LONG)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE)) + Handle->ActiveIncrementer->Special.Incrementer.Amount * Handle->IncrementerIncrement;
if(Number < Parent->Min)
Number = Parent->Min;
else
{
if(Number > Parent->Max)
Number = Parent->Max;
}
LT_SetAttributes(Handle,Parent->ID,
LAPR_Object, Parent,
GTIN_Number, Number,
TAG_DONE);
}
}
}
else
{
Handle->IncrementerIncrement = 1;
Handle->IncrementerAccelerate = 10;
}
if(Handle->IncrementerIncrement == 1)
Handle->IncrementerCountdown = 2;
}
}
break;
case IDCMP_RAWKEY:
{
UBYTE Buffer[10];
LONG Key;
struct InputEvent event;
BOOL KeyUp;
if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle->HelpHook)
{
if(!(*MsgCode & IECODE_UP_PREFIX))
{
ObjectNode *Item;
struct HelpMsg Message;
struct IBox Box;
Item = LTP_FindNode_Position(Handle->TopGroup,Handle->Window->MouseX,Handle->Window->MouseY);
if(Item == Handle->TopGroup)
{
if(Item->ID <= PHANTOM_GROUP_ID)
Item = NULL;
}
if(Item)
{
Message.Objec